/**
 * 
 */
package org.log4jconfig.xml.editor.contentassist.attribute;

import java.util.List;

import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.ui.ISharedImages;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.log4jconfig.xml.editor.utils.JdtUtils;
import org.log4jconfig.xml.editor.utils.Logger;

/**
 * @author Xi
 * 
 */
@SuppressWarnings("restriction")
public class AppenderClassContentAssistComputer extends AbstractContentAssistComputer {

	public void addAttributeValueProposals(IJavaProject javaProject, ContentAssistRequest contentAssistRequest,
			String attributeCurrentValue, String attributeMatchValue) throws Exception {
		IType type = JdtUtils.getTypeFromCurrentProject(javaProject, "org.apache.log4j.Appender");
		if (type == null) {
			Logger.warn("Could not find type 'org.apache.log4j.Appender' in project's classpath");
			return;
		}
		ITypeHierarchy hierarchy = JdtUtils.getTypeHierarchy(javaProject, type);
		List<String> values = JdtUtils.getClassesFromTypeHierarchy(javaProject, type, hierarchy);
		for (String value : values) {
			addCompletionProposal(contentAssistRequest, value, attributeCurrentValue, attributeMatchValue,
					ISharedImages.IMG_OBJS_CLASS);
		}
	}
}
